﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:l="clr-namespace:UIControls;assembly=UIControls"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:controls="clr-namespace:MyAnimelistRecommender.Controls"
        xmlns:tabControls="clr-namespace:MyAnimelistRecommender.Controls.TabControls"
        x:Class="MyAnimelistRecommender.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Background="{DynamicResource WindowBackgroundBrush}" Height="709" Width="920" Loaded="Window_Loaded" Closing="Window_Closing" d:DataContext="{d:DesignData /SampleData/RecommendationModelSampleData3.xaml}">
    <Window.Resources>
        <ControlTemplate x:Key="RefreshButtonTemplate" TargetType="{x:Type Button}">
            <Button Padding="{TemplateBinding Padding}">
                <TextBlock Text="P" Foreground="Black" FontWeight="ExtraLight" FontFamily="Wingdings 3" x:Name="rototototo" FontSize="14" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
                    <TextBlock.RenderTransform>
                        <RotateTransform x:Name="rototototoTransform" Angle="80"/>
                    </TextBlock.RenderTransform>
                </TextBlock>
            </Button>
            <ControlTemplate.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter TargetName="rototototo" Property="Opacity" Value="0.3"/>
                </Trigger>
                <Trigger Property="IsMouseOver" Value="True">
                    <Trigger.EnterActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="rototototoTransform" Storyboard.TargetProperty="Angle" RepeatBehavior="Forever">
                                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="440">
                                        <EasingDoubleKeyFrame.EasingFunction>
                                            <CubicEase EasingMode="EaseInOut"/>
                                        </EasingDoubleKeyFrame.EasingFunction>
                                    </EasingDoubleKeyFrame>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="rototototoTransform" Storyboard.TargetProperty="Angle">
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="80">
                                        <EasingDoubleKeyFrame.EasingFunction>
                                            <BackEase EasingMode="EaseOut"/>
                                        </EasingDoubleKeyFrame.EasingFunction>
                                    </EasingDoubleKeyFrame>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </BeginStoryboard>
                    </Trigger.ExitActions>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Window.Resources>
    <Grid Name="mainGrid">
        <Grid.LayoutTransform>
            <ScaleTransform x:Name="EndOfTheWorldTransformers" />
        </Grid.LayoutTransform>
        <Grid.Resources>
            <Storyboard x:Key="EndOfStory" Name="EndOfStory" Completed="Storyboard_Completed">
                <DoubleAnimation Storyboard.TargetName="EndOfTheWorldTransformers" Storyboard.TargetProperty="ScaleX" From="1" To="0" Duration="00:00:0.5"  />
                <DoubleAnimation Storyboard.TargetName="EndOfTheWorldTransformers" Storyboard.TargetProperty="ScaleY" From="1" To="0" Duration="00:00:0.5"  />
            </Storyboard>
        </Grid.Resources>
        <Grid IsEnabled="{Binding IsNotVeryBusy}" Margin="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <TabControl SelectedIndex="3">
                <TabItem x:Name="panelPh" Width="{Binding ActualWidth, ElementName=userPanel}" IsEnabled="False" Focusable="False" Visibility="Hidden" Height="28"/>
                <TabItem Width="10" IsEnabled="False" Focusable="False" Visibility="Hidden" Height="28"/>
                <TabItem Header="Animes" Grid.IsSharedSizeScope="True" >
                    <tabControls:Animes />
                </TabItem>
                <TabItem Header="Empfehlungen" >
                    <tabControls:Recommendations />
                </TabItem>
                <TabItem Header="Blacklist" Grid.IsSharedSizeScope="True" >
                    <tabControls:BlackList />
                </TabItem>
                <TabItem Header="Einstellungen" Grid.IsSharedSizeScope="True" >
                    <tabControls:Configuration />
                </TabItem>
            </TabControl>
            <Border HorizontalAlignment="Left" Margin="0 4 0 0" Height="{Binding ActualHeight, ElementName=panelPh}" VerticalAlignment="Top">
                <StackPanel VerticalAlignment="Center" x:Name="userPanel" Margin="0 0 0 0" Orientation="Horizontal" Grid.ColumnSpan="2">
                    <TextBox Text="{Binding UserName}" HorizontalAlignment="Left" Margin="0" x:Name="textBox1" Width="135" Padding="2,0" VerticalContentAlignment="Center" />
                    <ComboBox Margin="6,0,0,0" ItemsSource="{Binding SortingMode.Keys}" SelectedItem="{Binding SelectedSortingMode}" Width="150"/>

                    <Button VerticalAlignment="Center" Padding="0" Template="{StaticResource RefreshButtonTemplate}" IsEnabled="{Binding IsNotBusy}" Click="Button_Click_1" Margin="6,0,0,0" Width="{Binding ActualHeight, RelativeSource={RelativeSource Mode=Self}}" />
                </StackPanel>
            </Border>
            <l:SearchTextBox VerticalContentAlignment="Center" Search="SearchTextBox_Search" Text="{Binding SearchText, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"  HorizontalAlignment="Right" Margin="0 8 0 0" Width="125" Height="22" VerticalAlignment="Top" />
        </Grid>
        <controls:BusyIndicator IsBusy="{Binding IsVeryBusy}" />
    </Grid>
</Window>